POV-Ray : Newsgroups : povray.binaries.images : Help needed for random numbers : Re: Help needed for random numbers Server Time
14 Aug 2024 07:16:19 EDT (-0400)
  Re: Help needed for random numbers  
From: Slime
Date: 14 Nov 2002 13:35:50
Message: <3dd3ed06$1@news.povray.org>
rand() is random enough for most pusposes.

If you're not getting an equal distribution from it, then you're probably
using it wrong.

*looks at source code*

translate <rand(trans)+15,rand(trans)+10,-rand(trans)+15>
rotate  <rand(rot)*360,rand(rot)-21,rand(rot)*360>

Try rotating before translating.

What you're doing now, is translating it into a random position in the box
from <15,10,14> to <16,11,15>. Then you're rotating it (*around the origin*)
to a new position. This causes them to fill the area created by a sphere of
radius sqrt(16^2+11^2+15^2) differenced with a sphere of radius
sqrt(15^2+10^2+14^2), and causes their orientation to be relative to their
position to the origin.

So first rotate, then translate, like this:

rotate <rand(rot),rand(rot),rand(rot)>*360 // orient randomly
translate <rand(trans)+15,rand(trans)+10,-rand(trans)+15> // translate into
a random position in the box
rotate  -21*y // because you seem to want to rotate -21*y from your original
code

 - Slime
[ http://www.slimeland.com/ ]


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.